//
//  SPTabBarController.m
//  Sport
//
//  Created by Cass on 2018/2/7.
//  Copyright © 2018年 Cass. All rights reserved.
//

#import "SPTabBarController.h"
#import "SPIssueViewController.h"
#import "SPHomeViewController.h"
#import "SPMineViewController.h"
#import "SPMessageViewController.h"
#import "SPFriendsViewController.h"
#import "SPNavigationController.h"
#import "SPTabbar.h"

@interface SPTabBarController ()<SPTabbarDelegate>

@end

@implementation SPTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    SPTabbar *tabbar = [[SPTabbar alloc]init];
    tabbar.myDelegate = self;
     
    //kvc实质是修改了系统的_tabBar
    [self setValue:tabbar forKey:@"tabBar"];
    [self login];
}

- (void)login{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *phoneNumber = [userDefaults objectForKey:@"phoneNumber"];
    NSString *password = [userDefaults objectForKey:@"password"];
    [[EMClient sharedClient] loginWithUsername:phoneNumber password:password completion:^(NSString *aUsername, EMError *aError) {
        if (!aError) {
            NSLog(@"%@登录成功",aUsername);
        }else{
            NSLog(@"登录失败");
        }
    }];
}
#pragma mark - SPTabbarDelegate -
- (void)tabbarPlusBtnClick:(SPTabbar *)tabbar{
    SPIssueViewController *plusVC = [[UIStoryboard storyboardWithName:@"Issue" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPIssueViewController class])];
    SPNavigationController *navVC = [[SPNavigationController alloc]initWithRootViewController:plusVC];
    [self presentViewController:navVC animated:YES completion:nil];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
